from django.db import models
from django.db.models import permalink
from django.utils.translation import gettext_lazy as _

# Create your models here.
class Event(models.Model):
    title = models.CharField(maxlength = 50)
    description = models.TextField()
    country = models.CharField(maxlength = 50)
    city = models.CharField(maxlength = 50)
    place = models.CharField(maxlength = 50)
    street = models.CharField(maxlength = 50)
    start_date = models.DateField()
    end_date = models.DateField()
    lat = models.FloatField(max_digits=9, decimal_places=6)
    lng = models.FloatField(max_digits=9, decimal_places=6)
    class Admin:
		pass
	
    def save(self):
	if self.start_date >= self.end_date:
		return
	else:
	    super(Event,self).save()
    
    def __str__(self):
		return _('%(title)s at %(place)s') % {'title':self.title, 'place':self.place}
    
    @permalink
    def get_absolute_url(self):
		return ('eventr.main.views.show',[str(self.id)])